public class Solution {
    public int cutRope(int target) {

        if (target <= 3) {
            return target - 1;
        }

        int[] dp = new int[target + 1];
        dp[1] = 1;
        dp[2] = 2;
        dp[3] = 3;

        for (int i = 4; i <= target; i++) {
            for (int j = 1; j < i; j++) {
                dp[i] = Math.max(dp[i], j * dp[i - j]);
            }
        }

        return dp[target];
    }
}
